home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-21 / dvcron21.zip / CRON.DOC < prev    next >
Text File  |  1992-01-19  |  8KB  |  200 lines

  1. Cron 2.0
  2. (c) 1991 -- Kyle A. York
  3. ------------------------
  4.  
  5.   Here's my attempt to port the Unix Cron utility to MS-DOS. Feel free
  6.   to do with program as you please --but-- always leave my name in the
  7.   source and documentation and ALWAYS note any changes you have made. I
  8.   don't want bad code running around with my name on it.
  9.  
  10.   please read WHATSNEW
  11.  
  12. Acknowledgements
  13. ================
  14.  
  15.   Ralph Brown for his invaluable interrupt list and DVGLUE library.
  16.  
  17. Command Format
  18. ==============
  19.  
  20.   CRON [-c filename] [-d filename] [-l filename] [-l-] [-m memsize]
  21.  
  22.   -d filename : set the template .dvp file to filename
  23.   -c filename : set the CRONTAB file to filename (default is crontab
  24.                 in the same directory as cron.exe)
  25.   -l filename : set global logfile to filename (default is cron.log
  26.                 in the same directory as cron.exe)
  27.   -l-         : disable the global log file
  28.   -m memsize  : set the CRONTAB buffer to memsize. default is 1K.
  29.  
  30. CRONTAB format
  31. ==============
  32.  
  33.   the first 5 fields are: minute (0-59), hour (0-23), day of month (1-
  34.   31), month of year (1-12) and day of week (0-6, 0=sunday). A '*' is
  35.   used for "any allowable value". The fields are seperated by spaces.
  36.  
  37.   ex: 0 0 1,15 * 3 [switches] {command} [paramaters]; ...
  38.  
  39.   will execute the command at 00:00 on the 1st and 15th of every month
  40.   and on every Wednesday. The number list can be comma-seperated
  41.   (1,15) or ranges (1-5,6-9). VERY LITTLE error checking is done. If a
  42.   number is out of range, it will never be found so {command} will
  43.   never be executed. If a * appears anywhere in the field, the fields
  44.   will ALWAYS match (eg 1,2,4-7,*,9 is equivalent to *). A range is
  45.   assumed to be low to high. If it is entered high to low, only the
  46.   limits will match (eg 7-4 will match 7 and 4, but not 5 and 6
  47.   whereas 4-7 will match 4,5,6,7).
  48.  
  49.   {command} format
  50.  
  51.     This is where I had to deviate somewhat from the UNIX format. The
  52.     command can be optionally preceded by some switches as follows:
  53.  
  54.       -b        : force this window to start in the background
  55.       -c n      : if n < 0, set minimum conventional memory to -n K
  56.                 : if n > 0, set maximum conventional memory to n K
  57.                 : this might seem kind of clunky but its the best I could
  58.                 : think to do.
  59.       -e n      : set maximum expanded memory to n K
  60.       -h        : force this window to start hidden
  61.       -l name   : set local log file to name
  62.                   if name = "-", reset to normal global log file
  63.  
  64.     The local log file remains in effect for the line or until the "-l-"
  65.     switch is entered. If the command has the extension '.exe',
  66.     '.com', or '.dvp' it must also have the full path to reach the
  67.     file. In other words the DOS path is not traversed to find the
  68.     program. Any other extension (most notably ".bat") will load the
  69.     current command shell (normally COMMAND.COM) and pass the command
  70.     as a parameter.
  71.  
  72.     If the command has an extension '.exe' or '.com' the window is set
  73.     to close on completion. If it has a '.dvp' then the command is run
  74.     verbatim from the info in the '.dvp'. If it has any other
  75.     extension, the command interpreter is loaded and the command is
  76.     sent to the interpreter. Generally if you are running a batch file
  77.     and you want the window to close on completion, the last command
  78.     in the batch file should be 'exit'.
  79.  
  80.   parameters format
  81.  
  82.     The parameters string is parsed for the following strings:
  83.       %M, %D, %Y, %h, %m
  84.     If these are found, %M is replaces with the 2-digit month, %D with
  85.     the 2-digit day of month, %Y with the 2-digit year %h with the 2-
  86.     digit hour, and %m with the 2-digit minute. An example of this is
  87.     included in the example CRONTAB file. I needed a way to backup my
  88.     disks using a unique name, and the month + day strings worked
  89.     quite well.
  90.  
  91.     After this parsing, the parameters are sent to the program.
  92.  
  93.   commands may be "stacked" on a line
  94.  
  95.   eg:
  96.     5 6 * * * cmd1; cmd2; cmd3
  97.  
  98.   will execute command1, command 2, and command 3 at 06:05a. any
  99.   switches will remain in effect until either changed or the line ends
  100.  
  101.   eg:
  102.     5 6 * * * -c20 cmd1; cmd2; -c80 cmd3
  103.     5 6 * * * cmd4
  104.  
  105.   This will run cmd1 and cmd2 with 20K of conventional memory, and
  106.   cmd3 with 80K. cmd4 will get the default. since there is no undoing
  107.   "-b" (background) and "-h" (hide) these switches will remain in
  108.   effect until the end of the line and will be reset for the next
  109.   line.
  110.  
  111.   eg:
  112.     5 6 * * * -b cmd1; cmd2
  113.     5 6 * * * cmd3
  114.  
  115.   This will run cmd1 and cmd2 in the background, and cmd3 in the
  116.   default setting.
  117.  
  118.   Multiple commands on a line are started as multiple concurrent
  119.   processes. In other words in the above example, cron DOES NOT wait
  120.   for the completion of cmd1 before starting cmd2 and cmd3 so BE
  121.   CAREFUL not to run short on memory if you start multiple processes
  122.   simultaneously.
  123.  
  124.   If you need to send a ';' to your shell, simply use ';;'.
  125.  
  126.   eg:
  127.     5 6 * * * cmd parm1 ;; parm2 ;; parm3
  128.  
  129.   Will run cmd using parameters "parm1 ; parm2 ; parm3"
  130.  
  131. Limitations
  132.  
  133.   DESQview allows only 63 characters for the full path to the program,
  134.   and 63 characters for the parameters. If the parameters string is
  135.   greater than 63 characters it is truncated with a warning written to
  136.   the log file. If a '.bat' file is run, the path to the program is
  137.   cleared and the parameters are set to the program name + parameters
  138.   therefore the full string (program name + parameters) must be less
  139.   than 63 characters. If not it is truncated with a warning written to
  140.   the log file.
  141.  
  142.   Also, opening a new application is done using DVapp_start(). From
  143.   the DVGLUE documentation:
  144.     "This function is known to cause lockups under DV 2.00 (6-16-87).
  145.      Use at your own risk (though I would appreciate hearing from you
  146.      which version (and date) you are using and whether or not it
  147.      worked). [Ralph Brown]"
  148.   I have used this with DV 2.4 without problems, your mileage may
  149.   vary.
  150.  
  151.   When DESQview tries to open a new process and there is not enough
  152.   memory, it will write another process to disk (aka swapping).
  153.   Unfortunatly if memory later thins out, it will NOT automatically
  154.   retrieve a swapped process so be careful when starting numerous
  155.   commands.
  156.  
  157. Comments
  158.  
  159.   The CRONTAB file is opened when CRON begins and is left open while
  160.   CRON is running. Therefore it is HIGHLY RECOMMENDED that you also
  161.   load SHARE.EXE so one doesn't accidently deleted the file as this
  162.   would have highly unpredictable results. I use the timer functions
  163.   of DV so the amount of time spent in CRON is minimal. With a 3 line
  164.   CRONTAB file which executes commands once per day, and some once per
  165.   hour, my machine uses only about 1 minute / day for the CRON
  166.   process. Each minute, the first thing done is a check on CRONTAB to
  167.   see whether it's been modified. If it has, it is re-read. You will
  168.   note that there is no year entry in the CRONTAB file. This means
  169.   that a CRONTAB entry will never expire. If you set it to a certain
  170.   date (say 12 December) then it will execute only once per year.
  171.  
  172.   I have been using this program for about one week and have tried
  173.   every parameter but I cannot guarentee this will not crash. If it
  174.   does, or you have any other problems, please mail me at
  175.  
  176.     Internet:
  177.       noesis@ucscb.ucsc.edu
  178.       kyley@cats.ucsc.edu
  179.     CompuServe:
  180.       72125,1533
  181.  
  182. Technical Stuff
  183.  
  184.   This program was compiled with Turbo C 2.0 using the small memory
  185.   model and optimization set to 'size'. I've heard it said "never set
  186.   optimization to size" and always believed it until now. I felt there
  187.   was little speed gain to be had.
  188.  
  189.   I tried my best to keep this thing small, and am very happy with the
  190.   21K result. If you see somewhere that the code can be optimized
  191.   please let me know.
  192.  
  193. Registration
  194.  
  195.   If you use this program, please register it by mailing me at any
  196.   address above. If you would, include a brief description of your
  197.   setup and why you use cron. This is for my info only, if you do not
  198.   want to give me a description, that's fine but <<PLEASE>> let me
  199.   know who you are!
  200.